<%
# Copyright (C) 2013 - present Instructure, Inc.
#
# This file is part of Canvas.
#
# Canvas is free software: you can redistribute it and/or modify it under
# the terms of the GNU Affero General Public License as published by the Free
# Software Foundation, version 3 of the License.
#
# Canvas is distributed in the hope that it will be useful, but WITHOUT ANY
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
# A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
# details.
#
# You should have received a copy of the GNU Affero General Public License along
# with this program. If not, see <http://www.gnu.org/licenses/>.
%>

<%
  content_for :page_title, t('updated_terms_of_use', 'Updated Terms of Use')

  js_bundle :terms_of_use
  css_bundle :login_confirm
  disable_account_css

  @headers = false
  @body_classes ||= []
  @body_classes << "modal body--login-confirmation"
%>

<%= form_tag("/api/v1/users/self", method: "put", class: "reaccept_terms ic-Login-confirmation", id: "modal-box") do %>
  <header class="ic-Login-confirmation__header">
    <%= image_tag("login/canvas-logo@2x.png", class:"ic-Login-confirmation__logo", alt:"Canvas by Instructure") %>
  </header>
  <div class="ic-Login-confirmation__content">
    <h2 class="ic-Login-confirmation__headline"><%= t 'updated_terms_of_use', 'Updated Terms of Use' %></h2>
    <% if @domain_root_account.terms_required? %>
      <% TermsOfService.ensure_terms_for_account(@domain_root_account) %>
      <% js_env(:TERMS_OF_SERVICE_CUSTOM_CONTENT => @domain_root_account.terms_of_service.terms_of_service_content&.content) %>
      <% js_bundle :terms_of_service_modal %>
    <% end %>
    <p>
      <p>
        <div class="terms-of-service__link" id=terms_of_service_link></div>
        <%= t "Either you're a new user or the *terms of use* have changed since you last agreed to them.  Please agree to the *terms of use* before you continue.",
              wrapper: {
                  '*' => link_to('\1', "#", class: 'terms_of_service_link'),
              }
        %>
      </p>
      <label class="checkbox">
        <input type="checkbox" name="user[terms_of_use]" value="1">
        <%= agree_to_terms %>
      </label>
      <input type="hidden" name="redirect_to_previous" value="true" />
    </p>
    <div class="button_box ic-Login-confirmation__actions">
      <%= link_to(t("#buttons.cancel", "Cancel"), logout_path, :method => :delete, :class => "btn logout") %>
      <button type="submit" class="Button Button--primary"><%= t "#buttons.submit", "Submit" %></button>
    </div>
  </div>
<% end %>
